package ink.lovejinhu.leetcode;

/**
 * @author jinhu
 * created 2021-08-01 14:53
 */
public class Solution_0680 {
    /**
     * @param s
     * @return
     */
    public boolean validPalindrome(String s) {
        if (this.isHuiwen(s, Integer.MAX_VALUE)) {
            return true;
        } else {
            for (int i = 0; i < s.length(); i++) {
                if (isHuiwen(s, i)) {
                    return true;
                }
            }
            return false;
        }

    }

    public boolean isHuiwen(String s, int delete) {
        int start = 0;
        int end = s.length() - 1;
        for (; start < end; ) {
            if (start == delete) {
                start++;
            }
            if (end == delete) {
                end--;
            }
            if (s.charAt(start) == s.charAt(end)) {
                start++;
                end--;
            } else {
                return false;
            }

        }
        return true;
    }
}
